{%include file="m.index.header.tpl.php"%}
<!--头部 end--> 
<!--主体部分-->
<div class="container" style="margin-top:70px;">
  <div class="row row_margin">
    <form name="myform" action="" method="post" role="form" enctype="multipart/form-data">
    
     <div class="form-group">
        <label for="" class="col-sm-2  control-label">获奖名称：</label>
        <div class="col-sm-10 ">
           <input type="text" name="achieve_name" class="form-control" required>
         </div>
     </div>
	 {%if $type eq 6 %}

      <div class="form-group">
        <label for="" class="col-sm-2  control-label">出版社：</label>
        <div class="col-sm-10 ">
           <select class="form-control" id="s1" onchange="a()" name="achieve_publish">
				<option value=""> 请选择</option>
				{%foreach from=$publish_lists key=key item=value%}
				<option value="{%$value.publish_id%}">{%$value.publish_name%}</option>
				{%/foreach%}
				<option value="自定义"> 自定义</option>
			</select>
			<input id="new" class="form-control" placeholder="添加新的" name="resttype_name">
			<span class="btn btn-default" id="add" style="font-size:12px">添加</span>
         </div>
     </div> 
      <div class="form-group">
        <label for="" class="col-sm-2  control-label">书号：</label>
        <div class="col-sm-10 ">
          <input type="text" name="achieve_bookno" class="form-control" required>
        </div>
      </div>
      <div class="form-group">
        <label for="" class="col-sm-2  control-label">所在页：</label>
        <div class="col-sm-10 ">
          <input type="text" name="achieve_page" class="form-control" required>
        </div>
      </div>
	  {%/if%}
	  {%if $type neq 6 %}

       <div class="form-group">
        <label for="" class="col-sm-2  control-label">主办单位：</label>
        <div class="col-sm-10 ">
          <input type="text" name="achieve_unit" class="form-control" required>
        </div>
      </div>
	  {%if $type neq 7%}
       <div class="form-group">
        <label for="" class="col-sm-2  control-label">获奖名次：</label>
        <div class="col-sm-10 ">
         <select class="form-control" name="achieve_rank">
			{%foreach from=$prize key=key item=value%}
			<option value="{%$value.prize_id%}"> {%$value.prize_name%}</option>
			{%/foreach%}
		 </select>
        </div>
      </div>
     {%else%}
      <div class="form-group">
        <label for="" class="col-sm-2  control-label">第一指导老师：</label>
        <div class="col-sm-10 ">
			<select class="form-control" name="achieve_teach">
				{%foreach from=$teachers key=key item=value%}
				<option value="{%$value.staff_id%}"> {%$value.staff_name%}({%$value.staff_number%})</option>
				{%/foreach%}
			</select>
        </div>
      </div>
      
      <div class="form-group">
        <label for="" class="col-sm-2  control-label">本人名次：</label>
        <div class="col-sm-10 ">
         <input type="text" name="achieve_trank" class="form-control" required>
        </div>
      </div>
      {%/if%}
	  {%/if%}
      <div class="form-group">
        <label for="" class="col-sm-2  control-label">获奖级别：</label>
        <div class="col-sm-10 ">
         <select class="form-control" name="achieve_lv">
			{%foreach from=$prizelv key=key item=value%}
			<option value="{%$value.prizelv_id%}"> {%$value.prizelv_name%}</option>
			{%/foreach%}
		 </select>
        </div>
      </div>
	  <div class="form-group">
        <label for="" class="col-sm-2  control-label">{%if $type eq 6%}发表者{%else%}获奖人{%/if%}：</label>
        <div class="col-sm-10 ">
         {%if $type eq 5%}<input type="text" name="achieve_owner" id="achieve_owner" class="form-control" required>
		{%else%}<select class="form-control" name="achieve_owner">
			{%foreach from=$teachers key=key item=value%}
			<option value="{%$value.staff_id%}"> {%$value.staff_name%}({%$value.staff_number%})</option>
			{%/foreach%}
		</select>{%/if%}
        </div>
      </div>
	  <div class="form-group">
        <label for="" class="col-sm-2  control-label">{%if $type eq 6%}发表日期{%else%}获奖日期{%/if%}：</label>
        <div class="col-sm-10 ">
         <input type="text" class="form-control" name="achieve_time"  id="datepicker" />
        </div>
      </div>
	  {%if $type eq 5 %}
	  <div class="form-group">
        <label for="" class="col-sm-2  control-label">第一指导老师：</label>
        <div class="col-sm-10 ">
			<select class="form-control" name="achieve_teach">
				{%foreach from=$teachers key=key item=value%}
				<option value="{%$value.staff_id%}"> {%$value.staff_name%}({%$value.staff_number%})</option>
				{%/foreach%}
			</select>
        </div>
      </div>
	  <div class="form-group">
        <label for="" class="col-sm-2  control-label">其他指导老师：</label>
        <div class="col-sm-10 ">
			<select class="form-control select2" name="achieve_teachers[]" multiple="multiple" data-placeholder="选择老师（可多选）">
				{%foreach from=$teachers key=key item=value%}
				<option value="{%$value.staff_id%}"> {%$value.staff_name%}({%$value.staff_number%})</option>
				{%/foreach%}
			</select>
        </div>
      </div>
	  {%/if%}
	  <div class="form-group">
        <label for="" class="col-sm-2  control-label">附件：</label>
        <div class="col-sm-10 ">
         <input type="file"  name="achieve_file" multiple>
        </div>
      </div>
	  {%if $type eq 5%}
	  <div class="form-group">
        <label for="" class="col-sm-2  control-label">是否同步到指导老师奖：</label>
        <div class="col-sm-10 ">
         <input type="checkbox" name="same">
        </div>
      </div>
	  {%/if%}  
    </form>
  </div>
  <!--row  end-->
  
  <div class="row row_margin" style="margin-bottom:25px;" >
    <button type="submit" class="btn btn-primary btn-lg btn-block btn-primary2">确定</button>
  </div>
</div>
<!--container  end--> 
<!--主体部分  end--> 
<!--底部-->
{%include file="m.index.footer.tpl.php"%}
<script>
  $(function() {
    $( "#datepicker" ).datepicker({
      showOtherMonths: true,
      selectOtherMonths: true,
	  changeMonth: true,
      changeYear: true,
    });
	$( "#datepicker1" ).datepicker({
      showOtherMonths: true,
      selectOtherMonths: true,
	  changeMonth: true,
      changeYear: true
    });
	$( "#datepicker2" ).datepicker({
      showOtherMonths: true,
      selectOtherMonths: true,
	  changeMonth: true,
      changeYear: true
    });
	$( "#datepicker3" ).datepicker({
      showOtherMonths: true,
      selectOtherMonths: true,
	  changeMonth: true,
      changeYear: true
    });
  });
  //上传图片
  $(function(){
        var imgurl=[];
        function createfile(){
        $('#updiv').append("<input type='file'  name='photos' class='upfile'>");
        }
        function showimg(url){
            var img='<img src="'+url+'"/>';
            $('#imglist').append(img);
        }
        function addfile(){
            showimg($(this).val());
            $(this).hide();
            createfile();
            $('.upfile').bind('change',addfile);
        }
        $('.upfile').bind('change',addfile);
    })
</script>
{%if $type eq 5 %}
<script>
	$(function (){
		$('#achieve_owner').blur(function(){
			var name = $('#achieve_owner').val();
			$.post('index.php?a=achieve.checks',{name:name},function ($data) {
				if($data == 0){alert('未找到相应学生');}
			});
		})
	})
</script>
{%/if%}

{%if $type eq 6 %}
<script type="text/javascript">
	$(document).ready(function(){
		$("#new").hide();
		$("#add").hide();

		$("#add").click(function(){
			var na=$("#new").val();
			$.ajax({
				url:"index.php?a=publish.addajax&name="+na,
				type:"get",
				dataType: "json",
				success: function (msg) {
					//alert(msg);
					if(msg!=""){
						$("#s1").append("<option value='"+msg+"'>"+$("#new").val()+"</option>");
						$("#new").val('');
					}
				}
			});
		});
	});
	function a()
	{
		var val = $("#s1").val();
		if (val == '自定义') {
			$("#new").show();
			$("#add").show();
		} else{
			$("#new").hide();
			$("#add").hide();
		};
	}
</script>
{%/if%}
<script src="static/js/select2.min.js"></script>
 <script>
  $(function() {
    $(".select2").select2();
  });
  </script>
